package java_012_zuoye05;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;

public class DouDiZhu {
	@SuppressWarnings("unchecked")
	public static void main(String[] args) {
		HashMap<Integer,String> poker = new HashMap<>();
		//准备牌
		ArrayList<Integer> pokerIndex = new ArrayList<>();

		String[] colors={"♠","♣","♦","♥"};
		String[] numbers={"2","A","K","Q","J","10","9","8","7","6","5","4","3"};
		int index = 0;
		poker.put(index,"大王");
		pokerIndex.add(index);
		index++;
		poker.put(index,"小王");
		pokerIndex.add(index);
		index++;
		for(String number:numbers){
			for(String color:colors){
				poker.put(index,color+number);
				pokerIndex.add(index);
				index++;
			}
		}
		System.out.println(poker);
		//洗牌
		Collections.shuffle(pokerIndex);
		System.out.println(poker);

		Player p1=new Player();p1.setName("老王");
		Player p2=new Player();p2.setName("老李");
		Player p3=new Player();p3.setName("老六");
		ArrayList<Integer> dipai=new ArrayList<Integer>();
		//摸牌
		for(int i=0;i<poker.size();i++){
			//获取每一张的牌
            Integer p = pokerIndex.get(i);
			if(i>=51){
				dipai.add(p);
			}else if(i%3==0){
				p1.getPoker().add(p);
			}else if(i%3==1){
				p2.getPoker().add(p);
			}else if(i%3==2){
				p3.getPoker().add(p);
			}
		}
		Collections.sort(p1.getPoker());
		Collections.sort(p2.getPoker());
		Collections.sort(p3.getPoker());
		Collections.sort(dipai);

		//看牌
		System.out.print(p1.getName()+"的牌:");
		for(Integer key : p1.getPoker()){
			String value = poker.get(key);
			System.out.print(value +" ");
		}
		System.out.println(" ");
		
		System.out.print(p2.getName()+"的牌:");
		for(Integer key : p2.getPoker()){
			String value = poker.get(key);
			System.out.print(value +" ");
		}
		System.out.println(" ");
		
		System.out.print(p3.getName()+"的牌:");
		for(Integer key : p3.getPoker()){
			String value = poker.get(key);
			System.out.print(value +" ");
		}
		System.out.println(" ");
		
		System.out.print("底牌:");
		for(Integer key : dipai){
			String value = poker.get(key);
			System.out.print(value +" ");
		}
	}
}
